<?php

namespace App\Common;

class BusinessCode
{
    /* 表单验证类异常 【30001-31000】 */
    const VALIDATION_FAILED = 30001;

    /* 异常代码 【40001-41000】 */
    const RECORD_NOT_EXIST = 40001;

    const RECORD_ALREADY_EXIST = 40002;

    const RECORD_DELETE_NOT_ALLOWED = 40003;

    const RECORD_UPDATE_NOT_ALLOWED = 40004;

    const RECORD_CREATE_NOT_ALLOWED = 40005;

    /* 账号/登录相关错误代码 【41001-42000】 */
    const ACCOUNT_NOT_FOUND = 41001;

    const ACCOUNT_PWD_NOT_MATCH = 41002;

    const UNAUTHORIZED = 41003;

    const LOGIN_TIMES_EXCEED = 41004;

    /* 【42001-43000】 */
    const METHOD_NOT_SUPPORTED = 42001;

    /* Permission相关【43001-44000】 */
    const PERMISSION_NOT_ALLOWED = 43001;

    /* 系统错误代码 【50001-51000】 */
    const SYSTEM_ERROR = 500001;

    const ILLEGAL_OPERATION = 500002;

    /* 异常代码说明 */
    public static $businessCodeMap = [
        self::VALIDATION_FAILED => '数据校验失败',
        self::RECORD_NOT_EXIST => '数据不存在',
        self::RECORD_ALREADY_EXIST => '数据已存在',
        self::RECORD_DELETE_NOT_ALLOWED => '该数据不允许删除',
        self::RECORD_UPDATE_NOT_ALLOWED => '该数据不允许编辑',
        self::RECORD_CREATE_NOT_ALLOWED => '不允许创建该数据',

        self::ACCOUNT_NOT_FOUND => '用户账号不存在',
        self::ACCOUNT_PWD_NOT_MATCH => '账号密码不匹配',
        self::UNAUTHORIZED => '未登录或登录已过期',
        self::LOGIN_TIMES_EXCEED => '登录次数超限，请稍后重试',

        self::SYSTEM_ERROR => '系统错误',

        self::METHOD_NOT_SUPPORTED => '请求方法错误',

        self::PERMISSION_NOT_ALLOWED => '您没有该操作权限',
    ];
}
